<style>
	.myoverlay{position:fixed;z-index:999;width:100%;height:100%;background:#fefefe;opacity:0.9;
        filter:alpha(opacity=90);top:0;left:0;text-align:center;display:block;}
	.myoverlay img{margin-top:200px;}
</style>
<div style="display:none;">
    <{foreach from=$list item=v}>
        <span class="cus_id_item"><{$v.id}></span>
    <{/foreach}>
</div>
<div class="myoverlay">
	<img src="../public/img/loading.gif"/>
    <div style="margin-top:20px;font-size:16px;font-weight:bold;">
        <span style="color:#127676;" id="yfs">0</span>个公众号已发送，<span style="color:red;" id="sy">1000</span>个公众号未发送
    </div>
</div>
<script type="text/javascript">
    window.onbeforeunload = function(){ 
        return "您确定全部发送完了吗"; 
    }

    var customer_id;//公众号id
	var yfs_num=0;//已发送数
	var sy_num=parseInt($('.cus_id_item').length);//剩余数
    //发送
    function send(){
        customer_id=$('.cus_id_item').eq(0).text();
        $('#yfs').text(yfs_num);$('#sy').text(sy_num);
        
        //如果未返回正常json格式可能会使ajax中断，所以不用json格式传输
        $.post('bunch_send.php?v='+yfs_num,{a:'send',id:<{$smarty.get.id}>,customer_id:customer_id},function(){
            $('.cus_id_item').eq(0).remove();
            yfs_num++;sy_num--;
            $('#yfs').text(yfs_num);$('#sy').text(sy_num);
            if(sy_num == 0){
                $('.myoverlay img').hide();
            }else{
                send();
            }
        });
    }
    
    $(document).ready(function(){
        send();
    })
</script>